/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Model;

/**
 *
 * @author snowangelic
 */
public class Attribute {
    String name;
    AttributeType type;
    boolean manualRange;
    float minVal;
    float maxVal;

    Attribute(String n, AttributeType t,boolean manRange,float min,float max){
        name=n;
        type=t;
        manualRange=manRange;
        minVal=min;
        maxVal=max;
    }

    Attribute(String n, AttributeType t){
        name=n;
        type=t;
        manualRange=false;
        minVal=0;
        maxVal=0;
    }

    public void setRange(float min,float max){
        minVal=min;
        maxVal=max;
    }

    public float getMin(DataSet set){
        float min=0;
        if(isManualRange()) min=minVal;
        else{
            min=Float.MAX_VALUE;
            float curVal;
            for(int i=0;i<set.getActionNbr();i++){
                curVal= (Float) set.getValue(i,this);
                if(curVal<min) min=curVal;
            }
        }
        return min;
    }

    public float getMax(DataSet set){
        float max=0;
        if(isManualRange()) max=maxVal;
        else{
            max=Float.NEGATIVE_INFINITY;
            float curVal;
            for(int i=0;i<set.getActionNbr();i++){
                curVal= (Float) set.getValue(i,this);
                if(curVal>max) max=curVal;
            }
        }
        return max;
    }

    public boolean isManualRange(){
        return manualRange;
    }

    /**
     *
     * @return
     */
    public AttributeType getType(){
        return type;
    }

    /**
     *
     * @return
     */
    public String getName(){
        return name;
    }

}
